package com.echo.im.engin.netty.processor.preprocessor;

import com.echo.im.domain.common.MessageDTO;
import com.echo.im.domain.common.MessagePacket;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.Set;

/**
 * @author: echo
 * @time: 2024-08-22
 */
@Component
@RequiredArgsConstructor
public class PreprocessorContext {

    public final List<MessageInPreprocessor> preprocessors;


    public void doPreprocess(MessageDTO<? extends MessagePacket> messageDTO){
        for (MessageInPreprocessor preprocessor : preprocessors) {
            if (preprocessor.support(messageDTO.getPacket().getType())){
                preprocessor.doPreprocess(messageDTO);
                break;
            }
        }
    }

}
